import { BasePageDto } from '@/common/base/base.dto';
import { ApiProperty, ApiPropertyOptional, OmitType, PartialType } from '@nestjs/swagger';
import {
  IsBooleanString,
  IsInt,
  IsNotEmpty,
  IsOptional,
  IsString,
  IsUUID,
  Max,
  Min,
} from 'class-validator';

export class RoleResourceAdminAllDto {
  @IsOptional()
  @ApiPropertyOptional()
  @IsUUID()
  parentUuid?: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  name?: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsBooleanString()
  isChild?: string;
}

export class RoleResourceAdminCreateDto {
  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  name: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsUUID()
  parentUuid?: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsInt()
  @Max(999)
  @Min(1)
  sort: number;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  img: string;
}

export class RoleResourceAdminUpdateDto extends OmitType(PartialType(RoleResourceAdminCreateDto), ['parentUuid']) {}
